<template>
  <div class="box">
    <a-card :bordered="false" class="search">
      <div class="searchBox">
        <a-input placeholder="请输入订单号" v-model="queryParam.order_no">
          <a-icon slot="suffix" type="search" />
        </a-input>
        <span style="margin-top: 14px; margin-right: 10px">下单时间:</span>
        <a-range-picker
          style="margin-top: 14px;margin-right: 10px"
          :show-time="{ format: 'HH:mm' }"
          format="YYYY-MM-DD HH:mm"
          valueFormat="YYYY-MM-DD HH:mm"
          :placeholder="['开始时间', '结束时间']"
          v-model="queryTime"
          @change="changeTime"
        />
        <span style="margin-top: 14px; margin-right: 10px">生成时间:</span>
        <a-range-picker
          style="margin-top: 14px"
          :show-time="{ format: 'HH:mm' }"
          format="YYYY-MM-DD HH:mm"
          valueFormat="YYYY-MM-DD HH:mm"
          :placeholder="['开始时间', '结束时间']"
          v-model="queryTime1"
          @change="changeTime1"
        />
        <a-button type="primary" @click="getList" style="margin-left:10px;">查询</a-button>
      </div>
    </a-card>
    <a-card :bordered="false" class="card_style_re">
      <a-page-header :breadcrumb="{ props: { routes } }" />
      <a-table
        :rowKey="
          (r, i) => {
            return i
          }
        "
        :pagination="{
          total: this.totalCount,
          showSizeChanger: false,
          onChange: this.tablePageChange,
        }"
        :columns="columns"
        :data-source="list"
        :scroll="{ x: 'max-content' }"
      >
        <span slot="pay_time" slot-scope="text">
          {{ text > 0 ? $moment(text * 1000).format('YYYY-MM-DD HH:mm:ss') : '-' }}
        </span>
        <span slot="created_at" slot-scope="text">
          {{ text > 0 ? $moment(text * 1000).format('YYYY-MM-DD HH:mm:ss') : '-' }}
        </span>
        <span slot="money" slot-scope="text"> ￥{{ text || 0 }} </span>
        <span slot="pay_price" slot-scope="text"> ￥{{ text || 0 }} </span>
      </a-table>
    </a-card>
  </div>
</template>

<script>
import { poolDetail } from '@/api/shareholder'
const columns = [
  {
    title: 'ID',
    dataIndex: 'id',
  },
  {
    title: '订单号',
    dataIndex:'order_no'
  },
  {
    title: '订单金额',
    dataIndex: 'pay_price',
    scopedSlots: {
      customRender: 'pay_price',
    },
  },
  {
    title: '股东分红金额',
    dataIndex: 'money',
    scopedSlots: {
      customRender: 'money',
    },
  },
  {
    title: '下单时间',
    dataIndex: 'pay_time',
    scopedSlots: {
      customRender: 'pay_time',
    },
    sorter: (a, b) => a.audit_time - b.audit_time,
  },
  {
    title: '生成时间',
    dataIndex: 'created_at',
    scopedSlots: {
      customRender: 'created_at',
    },
    sorter: (a, b) => a.audit_time - b.audit_time,
  }
]
export default {
  data() {
    return {
      // 搜索参数
      queryParam: {
        pool_level_id:null,
        pay_start_time: null,
        pay_end_time: null,
        create_start_time: null,
        create_end_time: null,
        profit_type:null,
        order_no: null,
        pageNo: 1,
        pageSize: 10,
      },
      // 请求的数据列表
      list: [],
      // 表格列配置
      columns,
      // 数据条数
      totalCount: 0,
      // 下单时间
      queryTime:[],
      // 生成时间
      queryTime1:[],
      routes: [
        {
          path: 'plugins/shareholder/pricePool',
          breadcrumbName: '股东奖金池',
        },
        {
          path: 'plugins/shareholder/bonus',
          breadcrumbName: '奖金池金额',
        },
      ],
    }
  },
  methods: {
    // 获取数据列表
    async getList() {
      const hide = this.$message.loading('加载中', 0)
      const res = await poolDetail(this.queryParam)
      if (res.code == 0) {
        this.totalCount = res.data.totalCount
        this.list = res.data.data
      }
      hide()
    },
    // 分页请求
    tablePageChange(e) {
      this.queryParam.pageNo = e
      this.getList()
    },
    // 切换筛选时间
    changeTime(e) {
      if (e.length) {
        this.queryParam.pay_start_time = e[0]
        this.queryParam.pay_end_time = e[1]
      } else {
        this.queryParam.pay_start_time = null
        this.queryParam.pay_end_time = null
      }
    },
    // 切换筛选时间
    changeTime1(e) {
      if (e.length) {
        this.queryParam.create_start_time = e[0]
        this.queryParam.create_end_time = e[1]
      } else {
        this.queryParam.create_start_time = null
        this.queryParam.create_end_time = null
      }
    }
  },
  mounted() {
    if(this.$route.query.id) {
      this.queryParam.pool_level_id = this.$route.query.id
      this.getList()
    }
  },
}
</script>

<style lang="less" scoped>
.search {
  /deep/ .ant-card-body {
    padding-top: 0 !important;
    padding-bottom: 14px !important;
  }
}
.searchBox {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  /deep/ .ant-input-affix-wrapper {
    width: 220px;
    margin-top: 14px;
    margin-right: 20px;
  }
  .select {
    display: flex;
    align-items: center;
    margin-top: 14px;
    margin-right: 20px;
  }
  .ant-btn {
    margin-top: 14px;
  }
}
.name {
  display: flex;
  align-items: center;
  .pic {
    width: 48px;
    min-width: 48px;
    height: 48px;
    border-radius: 4px;
    overflow: hidden;
    margin-right: 24px;
    img {
      width: 100%;
      height: 100%;
    }
  }
  .info {
    flex: auto;
    width: 0;
    display: flex;
    flex-direction: column;
    font-size: 14px;
    span {
      width: 100%;
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;
    }
    span:nth-child(2) {
      color: rgba(0, 0, 0, 0.45);
      margin-top: 6px;
    }
  }
}
.action {
  display: flex;
  align-items: center;
  .line {
    width: 1px;
    height: 14px;
    background-color: #d8d8d8;
  }
}
.level_one_count {
  text-decoration: underline;
  cursor: pointer;
  color: #ff4400;
}
</style>